<template>
  <div>
    <img v-if="imgSrc" style="width: 100%; height: 100%" :src="imgSrc" alt="" />
    <img v-else src="../assets/images/imgLoading3.gif" style="width: 100%; height: 100%" alt="" />
  </div>
</template>

<script>
// 头像查看组件
import { mapGetters } from "vuex";
import { get_files } from "@/api/user.js";
export default {
  name: "commonImgView",
  components: {},
  props: {
    bizType: {
      require: false,
    },
    bizId: {
      require: false,
    },
  },
  computed: {
    ...mapGetters(["fileUrl"]),
  },
  data() {
    return {
      imgSrc: "",
    };
  },
  created() {
    this.loadFile();
  },
  methods: {
    async loadFile() {
      let data = {
        bizId: this.bizId,
        bizType: this.bizType,
      };
      await get_files(data).then((res) => {
        if (res.succeed) {
          for (let i = 0; i < res.data.length; i++) {
            res.data[i].url = this.fileUrl + res.data[i].url;
          }
          this.imgSrc = res.data[0]
            ? res.data[0].url
            : "../assets/images/noImgHead.png";
          // this.$emit("fileLoad", res.data);
        }
      });
    },
  },
};
</script>
<style scoped>
</style>